In [1]:
import numpy as np
import h5py
from os import path, rename
from shutil import copyfile
from glob import glob
In [7]:
base_dir = '/u/ki/swmclau2/des/Aemulators'
orig_fnames = [#'ds_zheng07/PearceDsCosmo.hdf5', 'ds_zheng07_test/PearceDsCosmoTest.hdf5',
#'ds_hsab/PearceDsHSABCosmo.hdf5']#,
'ds_hsab_test2/PearceDsHSABCosmoTest.hdf5']#,
#'ds_cab/PearceDsCABCosmo.hdf5', 'ds_cab_test/PearceDsCABCosmoTest.hdf5',
#'ds_corrab/PearceDsCorrABCosmo.hdf5', 'ds_corrab_test/PearceDsCorrABCosmoTest.hdf5']
In [8]:
tmp_fname = 'tmp.hdf5'
In [9]:
def h_factor(h):
return np.log10(h)*2
In [10]:
for fname in orig_fnames:
print fname
orig_fname = path.join(base_dir, fname)
dirname = path.dirname(orig_fname)
new_fname = path.join(dirname, tmp_fname)
copyfile(orig_fname, new_fname)
with h5py.File(orig_fname, 'r') as orig_f, h5py.File(new_fname, 'a') as new_f:
little_hs = orig_f.attrs['cosmo_param_vals'][:, 4]/100
#print len(little_hs)
keys = orig_f.keys()
if 'attrs' in keys:
keys.remove('attrs')
for h, dset_key in zip(little_hs, keys):
orig_data = orig_f[dset_key]['a_1.000']['obs']
new_data = orig_data+h_factor(h)
new_f[dset_key]['a_1.000']['obs'][()] = new_data
# TODO cov as well
rename(orig_fname, orig_fname + '_old')
copyfile(new_fname, orig_fname)
In [ ]:
%%bash
ls /u/ki/swmclau2/des/ds_cab/*.hdf5* -ltr
In [ ]:
mock_measurements_dir = '/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/mock_measurements/'
In [ ]:
mock_measurements_files = glob(path.join(mock_measurements_dir, '*ds.npy'))
In [ ]:
darksky_h = 0.7036893781978598
In [ ]:
covmat_dir = '/u/ki/swmclau2/Git/pearce/bin/covmat/'
In [ ]: